const {ccclass, property} = cc._decorator;

@ccclass
export default class SoundManager extends cc.Component {
    private static instance:SoundManager;
    static get Instance(){
        return this.instance;
    }


    @property(cc.AudioClip)
    bgm:cc.AudioClip;
    @property(cc.AudioClip)
    buttonSound:cc.AudioClip;
    @property(cc.AudioClip)
    winSound:cc.AudioClip;
    @property(cc.AudioClip)
    failSound:cc.AudioClip;

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        SoundManager.instance = this;
        cc.game.addPersistRootNode(this.node);
    }

    start () {
    }

    // update (dt) {}

    PlayBgm(){
        console.log(this.bgm);
        cc.audioEngine.playMusic(this.bgm, true);
    }

    PlayButton(){
        console.log(this.buttonSound);
        cc.audioEngine.playEffect(this.buttonSound, false);
    }

    PlayWin(){
        cc.audioEngine.playEffect(this.winSound, false);
    }

    PlayFail(){
        cc.audioEngine.playEffect(this.failSound, false);
    }
}
